package
{
	import flash.display.MovieClip;
	import flash.display.Screen;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.ProgressEvent;
	import flash.geom.Rectangle;
	import flash.utils.getDefinitionByName;
	
	import spark.components.WindowedApplication;
	
	[SWF(backgroundColor="#000000")]
	public class TouchAirPortfolio extends MovieClip
	{
		private var application:Sprite;
		
		public function TouchAirPortfolio()
		{
			stage.nativeWindow.width = 1680;
			stage.nativeWindow.height = 1050;
			
			var screenBounds:Rectangle = Screen.mainScreen.bounds;
			stage.nativeWindow.x = Math.floor(stage.width/2);
			stage.nativeWindow.y = Math.floor(stage.height/2);
			
			stage.nativeWindow.visible = true;
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.addEventListener(Event.RESIZE, resizeHandler);
			resizeHandler();

			loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
			loaderInfo.addEventListener(Event.COMPLETE, completeHandler);
		}
		
		private function progressHandler(event:ProgressEvent):void
		{
			var percent:Number = Math.round(event.bytesLoaded/event.bytesTotal * 100 );
		}
		
		private function completeHandler(event:Event):void
		{
			gotoAndStop(2);
			var applicationClass:Class = getDefinitionByName("com.touchportfolio.Application") as Class;
			application = new applicationClass();
			//removeChild(preloader);
			addChild(application);
		}
		
		private function resizeHandler(event:Event = null):void
		{
			//preloader.x = stage.stageWidth / 2 - preloader.width / 2;
			//preloader.y = stage.stageHeight / 2 - preloader.height / 2;
		}
	}
}